float (*from_linear_blue) (void *trc, float value);
float * matrixf = conversion->conversion.data;
- const float mat[9] = {matrixf[0], matrixf[1],matrixf[2],
- matrixf[3], matrixf[4],matrixf[5],
- matrixf[6], matrixf[7],matrixf[8]};
int i;
float *rgba_in = (void*)src_char;
float *rgba_out = (void*)dst_char;
for (i = 0; i < samples; i++)
{
- rgba_out[0]=to_linear_red(to_trc_red, rgba_in[0]);
- rgba_out[1]=to_linear_green(to_trc_green, rgba_in[1]);
- rgba_out[2]=to_linear_blue(to_trc_blue, rgba_in[2]);
- rgba_out[3]=rgba_in[3];
+ rgba_out[i*4] =to_linear_red(to_trc_red, rgba_in[i*4]);
+ rgba_out[i*4+1]=to_linear_green(to_trc_green, rgba_in[i*4+1]);
+ rgba_out[i*4+2]=to_linear_blue(to_trc_blue, rgba_in[i*4+1]);
+ rgba_out[i*4+3]=rgba_in[3];
+ }
- babl_matrix_mul_vectorff (mat, rgba_out, rgba_out);
+ babl_matrix_mul_vectorff_buf4 (matrixf, rgba_out, rgba_out, samples);
+ for (i = 0; i < samples; i++)
+ {
rgba_out[0] = from_linear_red(from_trc_red, rgba_out[0]);
rgba_out[1] = from_linear_green(from_trc_green, rgba_out[1]);
rgba_out[2] = from_linear_blue(from_trc_blue, rgba_out[2]);
float (*to_linear_blue) (void *trc, float value);
float * matrixf = conversion->conversion.data;
- const float mat[9] = {matrixf[0], matrixf[1],matrixf[2],
- matrixf[3], matrixf[4],matrixf[5],
- matrixf[6], matrixf[7],matrixf[8]};
int i;
float *rgba_in = (void*)src_char;
float *rgba_out = (void*)dst_char;
for (i = 0; i < samples; i++)
{
- rgba_out[0]=to_linear_red(to_trc_red, rgba_in[0]);
- rgba_out[1]=to_linear_green(to_trc_green, rgba_in[1]);
- rgba_out[2]=to_linear_blue(to_trc_blue, rgba_in[2]);
- rgba_out[3]=rgba_in[3];
-
- babl_matrix_mul_vectorff (mat, rgba_out, rgba_out);
-
+ rgba_out[i*4]=to_linear_red(to_trc_red, rgba_in[0]);
+ rgba_out[i*4+1]=to_linear_green(to_trc_green, rgba_in[1]);
+ rgba_out[i*4+2]=to_linear_blue(to_trc_blue, rgba_in[2]);
+ rgba_out[i*4+3]=rgba_in[3];
rgba_in += 4;
- rgba_out += 4;
}
+ babl_matrix_mul_vectorff_buf4 (matrixf, rgba_out, rgba_out, samples);
+
return samples;
}
rgb[i*3+2]=in_trc_lut[rgba_in_u8[i*4+2]];
}
- for (i = 0; i < samples; i++)
- {
- babl_matrix_mul_vectorff (matrixf, &rgb[i*3], &rgb[i*3]);
- }
+ babl_matrix_mul_vectorff_buf3 (matrixf, rgb, rgb, samples);
{
const Babl *from_trc_red = (void*)destination_space->space.trc[0];
rgba_out[i*3+1]=in_trc_lut[rgba_in_u8[i*4+1]];
rgba_out[i*3+2]=in_trc_lut[rgba_in_u8[i*4+2]];
rgba_out[i*3+2]=rgba_in_u8[i*4+3] / 255.0;
- babl_matrix_mul_vectorff (matrixf, &rgba_out[i*4], &rgba_out[i*4]);
}
+ babl_matrix_mul_vectorff_buf4 (matrixf, rgba_out, rgba_out, samples);
return samples;
}
universal_rgba_converter (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
float *matrixf = conversion->conversion.data;
- float mat[9] = {matrixf[0], matrixf[1],matrixf[2],
- matrixf[3], matrixf[4],matrixf[5],
- matrixf[6], matrixf[7],matrixf[8]};
- int i;
float *rgba_in = (void*)src_char;
float *rgba_out = (void*)dst_char;
- for (i = 0; i < samples; i++)
- {
- babl_matrix_mul_vectorff (mat, rgba_in, rgba_out);
- rgba_out[3] = rgba_in[3];
- rgba_in += 4;
- rgba_out += 4;
- }
+ babl_matrix_mul_vectorff_buf4 (matrixf, rgba_in, rgba_out, samples);
return samples;
}
universal_rgb_converter (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
float *matrixf = conversion->conversion.data;
- float mat[9] = {matrixf[0], matrixf[1],matrixf[2],
- matrixf[3], matrixf[4],matrixf[5],
- matrixf[6], matrixf[7],matrixf[8]};
- int i;
float *rgb_in = (void*)src_char;
float *rgb_out = (void*)dst_char;
- for (i = 0; i < samples; i++)
- {
- babl_matrix_mul_vectorff (mat, rgb_in, rgb_out);
- rgb_in += 3;
- rgb_out += 3;
- }
+ babl_matrix_mul_vectorff_buf3 (matrixf, rgb_in, rgb_out, samples);
return samples;
}
static inline void babl_matrix_mul_vector (const double *mat, const double *v_in, double *v_out)
{
- double val[3]={v_in[0], v_in[1], v_in[2]};
-
- v_out[0] = m(mat, 0, 0) * val[0] + m(mat, 0, 1) * val[1] + m(mat, 0, 2) * val[2];
- v_out[1] = m(mat, 1, 0) * val[0] + m(mat, 1, 1) * val[1] + m(mat, 1, 2) * val[2];
- v_out[2] = m(mat, 2, 0) * val[0] + m(mat, 2, 1) * val[1] + m(mat, 2, 2) * val[2];
+ double a = v_in[0], b = v_in[1], c = v_in[2];
+ double m_0_0 = m(mat, 0, 0);
+ double m_0_1 = m(mat, 0, 1);
+ double m_0_2 = m(mat, 0, 2);
+ double m_1_0 = m(mat, 1, 0);
+ double m_1_1 = m(mat, 1, 1);
+ double m_1_2 = m(mat, 1, 2);
+ double m_2_0 = m(mat, 2, 0);
+ double m_2_1 = m(mat, 2, 1);
+ double m_2_2 = m(mat, 2, 2);
+
+ v_out[0] = m_0_0 * a + m_0_1 * b + m_0_2 * c;
+ v_out[1] = m_1_0 * a + m_1_1 * b + m_1_2 * c;
+ v_out[2] = m_2_0 * a + m_2_1 * b + m_2_2 * c;
}
static inline void babl_matrix_mul_vectorf (const double *mat, const float *v_in, float *v_out)
{
- float val[3]={v_in[0], v_in[1], v_in[2]};
-
- v_out[0] = m(mat, 0, 0) * val[0] + m(mat, 0, 1) * val[1] + m(mat, 0, 2) * val[2];
- v_out[1] = m(mat, 1, 0) * val[0] + m(mat, 1, 1) * val[1] + m(mat, 1, 2) * val[2];
- v_out[2] = m(mat, 2, 0) * val[0] + m(mat, 2, 1) * val[1] + m(mat, 2, 2) * val[2];
+ float a = v_in[0], b = v_in[1], c = v_in[2];
+ float m_0_0 = m(mat, 0, 0);
+ float m_0_1 = m(mat, 0, 1);
+ float m_0_2 = m(mat, 0, 2);
+ float m_1_0 = m(mat, 1, 0);
+ float m_1_1 = m(mat, 1, 1);
+ float m_1_2 = m(mat, 1, 2);
+ float m_2_0 = m(mat, 2, 0);
+ float m_2_1 = m(mat, 2, 1);
+ float m_2_2 = m(mat, 2, 2);
+
+ v_out[0] = m_0_0 * a + m_0_1 * b + m_0_2 * c;
+ v_out[1] = m_1_0 * a + m_1_1 * b + m_1_2 * c;
+ v_out[2] = m_2_0 * a + m_2_1 * b + m_2_2 * c;
}
static inline void babl_matrix_mul_vectorff (const float *mat, const float *v_in, float *v_out)
{
- float val[3]={v_in[0], v_in[1], v_in[2]};
+ float a = v_in[0], b = v_in[1], c = v_in[2];
+ float m_0_0 = m(mat, 0, 0);
+ float m_0_1 = m(mat, 0, 1);
+ float m_0_2 = m(mat, 0, 2);
+ float m_1_0 = m(mat, 1, 0);
+ float m_1_1 = m(mat, 1, 1);
+ float m_1_2 = m(mat, 1, 2);
+ float m_2_0 = m(mat, 2, 0);
+ float m_2_1 = m(mat, 2, 1);
+ float m_2_2 = m(mat, 2, 2);
+
+ v_out[0] = m_0_0 * a + m_0_1 * b + m_0_2 * c;
+ v_out[1] = m_1_0 * a + m_1_1 * b + m_1_2 * c;
+ v_out[2] = m_2_0 * a + m_2_1 * b + m_2_2 * c;
+}
+
+static inline void babl_matrix_mul_vectorff_buf3 (const float *mat, const float *v_in, float *v_out,
+ int samples)
+{
+ int i;
+ float m_0_0 = m(mat, 0, 0);
+ float m_0_1 = m(mat, 0, 1);
+ float m_0_2 = m(mat, 0, 2);
+ float m_1_0 = m(mat, 1, 0);
+ float m_1_1 = m(mat, 1, 1);
+ float m_1_2 = m(mat, 1, 2);
+ float m_2_0 = m(mat, 2, 0);
+ float m_2_1 = m(mat, 2, 1);
+ float m_2_2 = m(mat, 2, 2);
+ for (i = 0; i < samples; i ++)
+ {
+ float a = v_in[0], b = v_in[1], c = v_in[2];
+
+ v_out[0] = m_0_0 * a + m_0_1 * b + m_0_2 * c;
+ v_out[1] = m_1_0 * a + m_1_1 * b + m_1_2 * c;
+ v_out[2] = m_2_0 * a + m_2_1 * b + m_2_2 * c;
+ v_in += 3;
+ v_out += 3;
+ }
+}
+
+static inline void babl_matrix_mul_vectorff_buf4 (const float *mat, const float *v_in, float *v_out,
+ int samples)
+{
+ int i;
+ float m_0_0 = m(mat, 0, 0);
+ float m_0_1 = m(mat, 0, 1);
+ float m_0_2 = m(mat, 0, 2);
+ float m_1_0 = m(mat, 1, 0);
+ float m_1_1 = m(mat, 1, 1);
+ float m_1_2 = m(mat, 1, 2);
+ float m_2_0 = m(mat, 2, 0);
+ float m_2_1 = m(mat, 2, 1);
+ float m_2_2 = m(mat, 2, 2);
+ for (i = 0; i < samples; i ++)
+ {
+ float a = v_in[0], b = v_in[1], c = v_in[2];
+
+ v_out[0] = m_0_0 * a + m_0_1 * b + m_0_2 * c;
+ v_out[1] = m_1_0 * a + m_1_1 * b + m_1_2 * c;
+ v_out[2] = m_2_0 * a + m_2_1 * b + m_2_2 * c;
+ v_out[3] = v_in[3];
+ v_in += 4;
+ v_out += 4;
+ }
+}
- v_out[0] = m(mat, 0, 0) * val[0] + m(mat, 0, 1) * val[1] + m(mat, 0, 2) * val[2];
- v_out[1] = m(mat, 1, 0) * val[0] + m(mat, 1, 1) * val[1] + m(mat, 1, 2) * val[2];
- v_out[2] = m(mat, 2, 0) * val[0] + m(mat, 2, 1) * val[1] + m(mat, 2, 2) * val[2];
+static inline void babl_matrix_mul_vector_buf4 (const double *mat, const double *v_in, double *v_out,
+ int samples)
+{
+ int i;
+ double m_0_0 = m(mat, 0, 0);
+ double m_0_1 = m(mat, 0, 1);
+ double m_0_2 = m(mat, 0, 2);
+ double m_1_0 = m(mat, 1, 0);
+ double m_1_1 = m(mat, 1, 1);
+ double m_1_2 = m(mat, 1, 2);
+ double m_2_0 = m(mat, 2, 0);
+ double m_2_1 = m(mat, 2, 1);
+ double m_2_2 = m(mat, 2, 2);
+ for (i = 0; i < samples; i ++)
+ {
+ double a = v_in[0], b = v_in[1], c = v_in[2];
+
+ v_out[0] = m_0_0 * a + m_0_1 * b + m_0_2 * c;
+ v_out[1] = m_1_0 * a + m_1_1 * b + m_1_2 * c;
+ v_out[2] = m_2_0 * a + m_2_1 * b + m_2_2 * c;
+ v_out[3] = v_in[3];
+ v_in += 4;
+ v_out += 4;
+ }
}